package cn.ydt.ydt.shopping.webapi.controller;

import cn.ydt.ydt.common.resful.JsonResult;
import cn.ydt.ydt.pojo.shopping.dto.SimpleDailyDTO;
import cn.ydt.ydt.pojo.shopping.vo.SimpleDailyVO;
import cn.ydt.ydt.shopping.service.IDailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "日用品订单模块")
@RestController
@RequestMapping(value = "/daily",produces = "application/json;charset=utf-8")
public class DailyController {

    @Autowired
    private IDailyService dailyService;

    @ApiOperation("新增日用品订单")
    @PostMapping("/add")
    public JsonResult<Void> addDailyOrder(@Validated @RequestBody SimpleDailyDTO simpleDailyDTO){
        dailyService.AddDailyOrder(simpleDailyDTO);
        return JsonResult.ok();
    }

    @ApiOperation("根据userId查询订单列表")
    @GetMapping("/get/list")
    public JsonResult<List<SimpleDailyVO>> getDailyList(){
        List<SimpleDailyVO> list = dailyService.getDailyByUserId();
        return JsonResult.ok(list);
    }
}
